﻿<Window x:Class="Demos.Collections.View"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Local="clr-namespace:Demos.Collections"
        Title="Colecciones" Height="375" Width="550">
    <Window.Resources>
        <DataTemplate DataType="{x:Type Local:Caja}">
            <Grid>
                <Rectangle Stroke="Black" StrokeThickness="1"
                           Height="{Binding Altura}" Width="{Binding Anchura}">
                </Rectangle>
                <Label HorizontalContentAlignment="Center" Content="{Binding Contenido}"
                       Height="{Binding Altura}" Width="{Binding Anchura}">
                </Label>
            </Grid>
        </DataTemplate>

        <DataTemplate DataType="{x:Type Local:Flecha}">
            <Line X1="{Binding X1}" Y1="{Binding Y1}"
                  X2="{Binding X2}" Y2="{Binding Y2}"
                  Stroke="Black" StrokeThickness="1">
            </Line>
        </DataTemplate>
    </Window.Resources>
    
    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="50"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="50"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        
        <Label Grid.Row="0">Lista</Label>
        
        <ScrollViewer Grid.Row="1" Grid.ColumnSpan="4" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Hidden">
            <ListView Name="ListLTW" ItemsSource="{Binding ContenidoLista}"
                      SelectedIndex="{Binding IndiceListaSeleccionado, UpdateSourceTrigger=PropertyChanged}">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"></StackPanel>
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
            </ListView>
        </ScrollViewer>

        <Label Grid.Row="2">Lista enlazada</Label>

        <ScrollViewer Grid.Row="3" Grid.ColumnSpan="4" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Hidden">
            <ListView Name="LinkedListLTW" ItemsSource="{Binding ContenidoListaEnlazada}"
                      SelectedIndex="{Binding IndiceListaEnlazadaSeleccionado, UpdateSourceTrigger=PropertyChanged}">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"></StackPanel>
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
            </ListView>
        </ScrollViewer>
        
        <GroupBox Grid.Row="4" Grid.Column="0" Header="Añadir">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Label Grid.Column="0">Elemento:</Label>
                <TextBox Grid.Column="1" Width="Auto" 
                         Text="{Binding ElementoAAñadir, UpdateSourceTrigger=PropertyChanged}">
                </TextBox>
                <Button Grid.Row="1" Grid.ColumnSpan="2" Margin="5" Command="{Binding AñadirCommand}">Añadir</Button>
                <Button Grid.Row="2" Grid.ColumnSpan="2" Margin="5" Command="{Binding GenerarAlAzarCommand}">Generar al azar</Button>
            </Grid>
        </GroupBox>

        <GroupBox Grid.Row="4" Grid.Column="1" Header="Eliminar">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Label Grid.Column="0">Elemento:</Label>
                <TextBox Grid.Column="1" Width="Auto" IsReadOnly="True"
                         Text="{Binding ElementoAEliminar, UpdateSourceTrigger=PropertyChanged}">
                </TextBox>
                <Button Grid.Row="1" Grid.ColumnSpan="2" Margin="5" Command="{Binding EliminarCommand}">Eliminar</Button>
                <Button Grid.Row="2" Grid.ColumnSpan="2" Margin="5" Command="{Binding BorrarTodoCommand}">Borrar todo</Button>
            </Grid>
        </GroupBox>

        <GroupBox Grid.Row="4" Grid.Column="2" Header="Contiene">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Label Grid.Column="0">Elemento:</Label>
                <TextBox Grid.Column="1" Width="Auto"
                         Text="{Binding ElementoABuscar, UpdateSourceTrigger=PropertyChanged}">
                </TextBox>
                <Button Grid.Row="1" Grid.ColumnSpan="2" Margin="5" Command="{Binding BuscarCommand}">Buscar</Button>
                <Border Grid.Row="2" Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="LightGray" Margin="6" Height="20">
                    <TextBlock TextAlignment="Center"
                               Background="{Binding ResultadoBusqueda, UpdateSourceTrigger=PropertyChanged}">
                    </TextBlock>
                </Border>
            </Grid>
        </GroupBox>

        <GroupBox Grid.Row="4" Grid.Column="3" Header="Contador">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="20"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Label Grid.Column="0">Lista:</Label>
                <Border Grid.Column="1" Width="Auto" BorderThickness="1" BorderBrush="LightGray" Height="20">
                    <TextBlock TextAlignment="Center"
                               Text="{Binding ContadorLista, UpdateSourceTrigger=PropertyChanged}">
                    </TextBlock>
                </Border>
                <Label Grid.Column="0" Grid.Row="3">Lista enlazada:</Label>
                <Border Grid.Column="1" Grid.Row="3" Width="Auto" BorderThickness="1" BorderBrush="LightGray" Height="20">
                    <TextBlock TextAlignment="Center"
                               Text="{Binding ContadorListaEnlazada, UpdateSourceTrigger=PropertyChanged}">
                    </TextBlock>
                </Border>
            </Grid>
        </GroupBox>

        <GroupBox Grid.Row="5" Grid.ColumnSpan="4" Header="La acción afectará a">
            <Grid Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                    <ColumnDefinition></ColumnDefinition>
                </Grid.ColumnDefinitions>
                
                <RadioButton Grid.Column="0" HorizontalAlignment="Center"
                             IsChecked="{Binding SeleccionColeccion[0], UpdateSourceTrigger=PropertyChanged}">
                    Lista</RadioButton>
                <RadioButton Grid.Column="1" HorizontalAlignment="Center"
                             IsChecked="{Binding SeleccionColeccion[1], UpdateSourceTrigger=PropertyChanged}">
                    Lista enlazada</RadioButton>
                <RadioButton Grid.Column="2" HorizontalAlignment="Center"
                             IsChecked="{Binding SeleccionColeccion[2], UpdateSourceTrigger=PropertyChanged}">
                    Ambas</RadioButton>
            </Grid>
        </GroupBox>
    </Grid>
</Window>
